/***********************************************************************************
    Filename: CC2500_hal_rf.h

    Copyright 2007 Texas Instruments, Inc.
***********************************************************************************/

#ifndef  __CC2500_HAL_RF_H__
#define  __CC2500_HAL_RF_H__

#include "Typedef.h"

//----------------------------------------------------------------------------------
// Type declarations
//----------------------------------------------------------------------------------

// The following structure can be used when configuring the RF chip. SmartRF Studio
// can be used to export a predefined instance of this structure.
typedef struct {
    INT8U fsctrl1;    // Frequency synthesizer control.
    INT8U fsctrl0;    // Frequency synthesizer control.
    INT8U freq2;      // Frequency control word, high byte.
    INT8U freq1;      // Frequency control word, middle byte.
    INT8U freq0;      // Frequency control word, low byte.
    INT8U mdmcfg4;    // Modem configuration.
    INT8U mdmcfg3;    // Modem configuration.
    INT8U mdmcfg2;    // Modem configuration.
    INT8U mdmcfg1;    // Modem configuration.
    INT8U mdmcfg0;    // Modem configuration.
    INT8U channr;     // Channel number.
    INT8U deviatn;    // Modem deviation setting (when FSK modulation is enabled).
    INT8U frend1;     // Front end RX configuration.
    INT8U frend0;     // Front end RX configuration.
    INT8U mcsm0;      // Main Radio Control State Machine configuration.
    INT8U foccfg;     // Frequency Offset Compensation Configuration.
    INT8U bscfg;      // Bit synchronization Configuration.
    INT8U agcctrl2;   // AGC control.
    INT8U agcctrl1;   // AGC control.
    INT8U agcctrl0;   // AGC control.
    INT8U fscal3;     // Frequency synthesizer calibration.
    INT8U fscal2;     // Frequency synthesizer calibration.
    INT8U fscal1;     // Frequency synthesizer calibration.
    INT8U fscal0;     // Frequency synthesizer calibration.
    INT8U fstest;     // Frequency synthesizer calibration.
    INT8U test2;      // Various test settings.
    INT8U test1;      // Various test settings.
    INT8U test0;      // Various test settings.
    INT8U iocfg2;     // GDO2 output pin configuration.
    INT8U iocfg0;     // GDO0 output pin configuration.
    INT8U pktctrl1;   // Packet automation control.
    INT8U pktctrl0;   // Packet automation control.
    INT8U addr;       // Device address.
    INT8U pktlen;     // Packet length.
} CC2500_HAL_RF_CONFIG;

// For rapid chip configuration with a minimum of function overhead.
// The array has to be set up with predefined values for all registers.
typedef INT8U CC2500_HAL_RF_BURST_CONFIG[47];

// The chip status byte, returned by chip for all SPI accesses
typedef INT8U CC2500_HAL_RF_STATUS;



//----------------------------------------------------------------------------------
// Function declarations
//----------------------------------------------------------------------------------

void  CC2500_halRfConfig(const CC2500_HAL_RF_CONFIG* rfConfig, const INT8U* rfPaTable, INT8U rfPaTableLen);
void  CC2500_halRfBurstConfig(const CC2500_HAL_RF_BURST_CONFIG rfConfig, const INT8U* rfPaTable, INT8U rfPaTableLen);
void  CC2500_halRfResetChip(void);
INT8U CC2500_halRfGetChipId(void);
INT8U CC2500_halRfGetChipVer(void);
INT8U CC2500_halRfReadStatusReg(INT8U addr);
INT8U CC2500_halRfReadReg(INT8U addr);

CC2500_HAL_RF_STATUS CC2500_halRfWriteReg(INT8U addr, INT8U data);
CC2500_HAL_RF_STATUS CC2500_halRfWriteFifo(const INT8U* data, INT8U length);
CC2500_HAL_RF_STATUS CC2500_halRfReadFifo(INT8U* data, INT8U length);
CC2500_HAL_RF_STATUS CC2500_halRfStrobe(INT8U cmd);
CC2500_HAL_RF_STATUS CC2500_halRfGetTxStatus(void);
CC2500_HAL_RF_STATUS CC2500_halRfGetRxStatus(void);


/**********************************************************************************/
#endif